package com.zzuli.fitness.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzuli.fitness.entity.OrderInfo;
import com.zzuli.fitness.entity.User;
import com.zzuli.fitness.mapper.OrderInfoDao;
import com.zzuli.fitness.mapper.UserDao;
import com.zzuli.fitness.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("orderService")
public class OrderServiceImpl extends ServiceImpl<OrderInfoDao, OrderInfo> implements OrderService {
    @Autowired
    private OrderInfoDao orderInfoDao;

    @Autowired
    private UserDao userDao;

    @Override
    public List<OrderInfo> findAllOrderByOpenId(String openid) {
        User user = userDao.selectUserByOpenId(openid);
        return orderInfoDao.findAllOrderByUserId(user.getId());
    }

    @Override
    public OrderInfo findOrderInfoById(String id) {
        return orderInfoDao.findOrderInfoById(id);
    }

    @Override
    public int insertOrderInfo(OrderInfo orderInfo) {
        return orderInfoDao.insert(orderInfo);
    }
}
